/*
 用户管理接口封装
*/

import { request } from "../utils/reequest"

// 左侧菜单接口
export const getMenus =() =>{
  return request({
    method:"GET",
    url:"menus"
  })
}
//右侧用户数据
export const getUsers = params =>{
   return request({
     method:'GET',
     url:'users',
     params
   })
}
// 修改用户状态
export const putUsers = (uid,type)=>{
  return request({
     method:'PUT',
     url:`users/${uid}/state/${type}`
  })
}
// 添加用户
export const postUsers = params =>{
  console.log(params, '')
  return request({
    method:'POST',
    url:'users',
    data:{
      username:params.username,
      password:params.password,
      mobile:params.mobile,
      email:params.email
    }
  })
}
// 修改用户,根据 ID 查询用户信息
export const getUsersId = data =>{
  return request({
    method:'GET',
    url:`users/${data}`
  })
}
// 修改用户数据，编辑用户提交
export const putUsersId = data =>{
  return request({
    method:'PUT',
    url:`users/${data.id}`,
    data
  })
}
// 删除单个用户
export const deleteUsers = data =>{
  return request({
    method:'delete',
    url:`users/${data}`
  })
}
//角色列表
export const getUsersRoles =()=>{
  return request({
    method:'get',
    url:'roles'
  })
}
// 分配用户角色
export const putUsersIdRole = (ID,params) =>{
  console.log(params, '')
  return request({
    method:'put',
    url:`users/${ID.id}/role`,
    // params
    data:{
      rid: params
    }
  })
}
